;*****************************************************************************************************
;+
; NAME:
;
;      eTVLCT (enhanced TVLCT)
;
; PURPOSE:
;
;      This is the enhanced version of the standard IDL TVLCT
;      command. It loads new color vectors into the IGL internal color
;      vectors. Note that, unlike the standard TVLCT procedure, this
;      change is immediately reflected on the current IGL window. Also
;      note that it does NOT change the IDL color vectors.
;
;
; CALLING SEQUENCE:
;
;      eLOADCT, red, green, blue
;
; ARGUMENTS:
;
;     RED:     Vector specifying the red intensity values.
;
;     GREEN:   Vector specifying the green intensity values.
;
;     BLUE:    Vector specifying the blue intensity values.
;                 
; KEYWORD PARAMETERS:
;
;     GET:     Set this keyword to return the RGB internal color
;              vectors into the RED, GREEN and BLUE arguments.
;    
; PACKAGE:
;
;    Interactive Graphics Library (IGL)
;
; AUTHORS:
;
;        RAPHAEL SADOUN
;        Graduate Student
;        Institut d'Astrophysique de Paris
;        98 bis boulevard Arago
;        75014 PARIS FRANCE
;        E-mail: raphael.sadoun@gmail.com
;
;
; MODIFICATION HISTORY:
;
;     Written by: Raphael Sadoun, 24 April 2012
;-
;*****************************************************************************************************
PRO eTVLCT, red, green, blue, GET=get

  COMPILE_OPT idl2, HIDDEN
  ON_ERROR, 2

  ;; Initialize the global system variables
  IGL_InitSysVars

  ;; Get the internal IGL color table
  currentTable = IGL_GetSysVars('colorTable')

  ;; Get the current color vectors if requested
  IF KEYWORD_SET(get) THEN currentTable -> GetProperty, RED=red, GREEN=green, BLUE=blue $
  ELSE BEGIN                    ; Otherwise load the vectors into the internal IGL table
     
     currentTable -> SetProperty, RED=red, GREEN=green, BLUE=blue
     
     ;; If there is a current valid IGL window, load the color vectors
     ;; into its own color table
     currentWindow = IGL_GetCurrentWindow()
     
     IF OBJ_ISA_VALID(currentWindow,'IGL_Window') THEN BEGIN

        ;; Get the draw widget object associated with the window
        drawWidget = currentWindow -> Get('DRAWWIDGET')
        
        IF OBJ_ISA_VALID(drawWidget,'DRAWWIDGET') THEN BEGIN

           ;; Get the IGL_ColorTable object associated with the window
           drawWidget -> GetProperty, Color_Object=colorTable

           ;; Load the color vectors
           IF OBJ_ISA_VALID(colorTable,'IGL_ColorTable') THEN colorTable -> SetProperty, RED=red, GREEN=green, BLUE=blue

           ;; Refreshes window's content
           currentWindow -> DrawWindow, /BUFFERED_OUTPUT
        
        ENDIF

     ENDIF

  ENDELSE

END
